﻿(function (win, undefined) {
    //按钮
    //x,y:显示位置, imgs:状态图片
    F5Frame.register("F5Frame", function (cg) {
        this.Image = function () {
            //继承:对象冒充
            this.newMethod = F5Frame.ObjBase; //把_objbase方法赋给newMethod，
            this.newMethod(); //调用newMethod
            delete this.newMethod; //删除newMethod
            //创建图片
            this.Create = function (options) {
                this._x = options.x || 0;
                this._y = options.y || 0;

                this.setzOrder(options.zorder || this.zOrder);
                this.imgs = [options.file, ];
                this.setImage(options.file);
                this.setLayer(options.layer || this.zLayer);

                this._sx = options.sx || 0;
                this._sy = options.sy || 0;
                this._swidth = options.swidth || this._image.width - this._sx;
                this._sheight = options.sheight || this._image.height - this._sy;
                this._dwidth = options.dwidth || this._swidth;
                this._dheight = options.dheight || this._sheight;
                
                F5Frame.addGameObject(this);
                return this;
            }
            this.getWidth = function () {
                return this._swidth;
            }
            this.getHeight = function () {
                return this._sheight;
            }
            //绘制
            this.draw = function (dt, context) {
                if (this._show) {
                    if (this._sx != 0 || this._sy != 0) {
                        context.drawImage(this.getImage(), this._sx, this._sy, this._swidth, this._sheight,
                        this.getX(), this.getY(),this._dwidth, this._dheight);
                    }
                    else {
                        context.drawImage(this.getImage(), this.getX(), this.getY());
                    }
                    this.draw_pick(context);
                }
            }
        }
    });

})(window, undefined);